import {getCity} from "../api/request";
export default () => {
   let city = JSON.parse(localStorage.getItem('city'));
   
    if (!city) {
        return new Promise((resolve, reject) => {
            

            async function myFun(result){
                var cityName = result.name;          
                // map.setCenter(cityName);
                try {
                    const res = await getCity(cityName);
                 
                    localStorage.setItem('city', JSON.stringify(res.data.body));
                    return resolve(res.data.body);
          
                } catch (error) {
                    return reject({label:'未知'});                
                }
  
            }
            var myCity = new window.BMapGL.LocalCity();
            myCity.get(myFun); 


        })
        
    }
    return new Promise((resolve, reject) =>{
        resolve(city)
    });
    

}








